package com.ruicar.afs.cloud.seats.util;

import com.ruicar.afs.cloud.seats.condition.GroupUserCondition;
import com.ruicar.afs.cloud.seats.condition.ReleaseGroupCondition;
import com.ruicar.afs.cloud.seats.condition.SysUserDto;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author tiankai
 * @Describe 接口集数据再处理
 * Created on 2020-06-11
 */
public class ResultSetUtil {

    /**
     * @Describe 审批组模糊查询
     * Created on 2020-06-11
     */
    public static List search(String name, List<ReleaseGroupCondition> list) {
        List results = new ArrayList();
        Pattern pattern = Pattern.compile(name);
        for (int i = 0; i < list.size(); i++) {
            Matcher matcher = pattern.matcher((list.get(i)).getName());
            if (matcher.find()) {
                results.add(list.get(i));
            }
        }
        return results;
    }

    /**
     * @Describe 成员模糊查询
     * Created on 2020-06-11
     */
    public static List searchMember(String name, List<GroupUserCondition> list) {
        List results = new ArrayList();
        Pattern pattern = Pattern.compile(name);
        for (int i = 0; i < list.size(); i++) {
            Matcher matcher = pattern.matcher((list.get(i)).getUserName());
            if (matcher.find()) {
                results.add(list.get(i));
            }
        }
        return results;
    }

    /**
     * @Describe 用户信息查询
     * Created on 2020-06-11
     */
    public static List searchUserRealName(String name, List<SysUserDto> list) {
        List results = new ArrayList();
        Pattern pattern = Pattern.compile(name);
        for (int i = 0; i < list.size(); i++) {
            Matcher matcher = pattern.matcher((list.get(i)).getUserRealName());
            if (matcher.find()) {
                results.add(list.get(i));
            }
        }
        return results;
    }
}
